package com.gf.pf.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.gf.pf.mapper.RoleMapper;
import com.gf.pf.model.Role;
import com.gf.pf.model.RoleResource;
import com.gf.pf.model.Ztree;
import com.gf.pf.service.RoleService;

/**
 * @describe 角色
 * @date     2015年3月7日
 */
@Service
@Transactional
public class RoleServiceImpl implements RoleService {
	
	@Autowired
	private RoleMapper roleMapper;

	/* (non-Javadoc)
	 * @see com.gf.pf.service.RoleService#findRoles(java.lang.Long)
	 * 根据用户ID查询角色
	 */
	@Override
	public List<Role> getRoles(String userId) {
		return roleMapper.getRoles(userId);
	}

	/* (non-Javadoc)
	 * @see com.gf.pf.service.RoleService#saveRole(com.gf.pf.model.Role)
	 * 保存角色
	 */
	@Override
	public Integer saveRole(Role role) {
		return roleMapper.saveRole(role);
	}

	/* (non-Javadoc)
	 * @see com.gf.pf.service.RoleService#getRole(java.lang.String)
	 * 根据角色ID查询角色信息
	 */
	@Override
	public Role getRole(String roleId) {
		return roleMapper.getRole(roleId);
	}

	/* (non-Javadoc)
	 * @see com.gf.pf.service.RoleService#modifyRole(com.gf.pf.model.Role)
	 * 修改角色
	 */
	@Override
	public Integer modifyRole(Role role) {
		return roleMapper.modifyRole(role);
	}

	/* (non-Javadoc)
	 * @see com.gf.pf.service.RoleService#deleteRole(java.lang.String)
	 * 删除角色
	 */
	@Override
	public Integer deleteRole(String roleId) {
		return roleMapper.deleteRole(roleId);
	}

	/* (non-Javadoc)
	 * @see com.gf.pf.service.RoleService#getResourceByRole(java.lang.String)
	 * 根据角色ID查询所包含的资源
	 */
	@Override
	public List<Ztree> getResourceByRole(String roleId) {
		return roleMapper.getResourceByRole(roleId);
	}

	/* (non-Javadoc)
	 * @see com.gf.pf.service.RoleService#deleteRoleResource(java.lang.String)
	 * 删除角色所包含的资源
	 */
	@Override
	public Integer deleteRoleResource(String roleId) {
		return roleMapper.deleteRoleResource(roleId);
	}

	/* (non-Javadoc)
	 * @see com.gf.pf.service.RoleService#saveRoleResource(com.gf.pf.model.RoleResource)
	 * 保存角色所包含的资源
	 */
	@Override
	public Integer saveRoleResource(RoleResource rr) {
		return roleMapper.saveRoleResource(rr);
	}

}
